/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import BUS.CTPhieuDatPhong_BUS;
import BUS.CTPhieuDatTiec_BUS;
import BUS.CTPhieuDichVu_BUS;
import BUS.CTPhieuThuePhong_BUS;
import BUS.DichVu_BUS;
import BUS.DoanhThuTheoLoaiPhong_BUS;
import BUS.HoaDon_BUS;
import BUS.KhachHang_BUS;
import BUS.MonAn_BUS;
import BUS.PhieuDatPhong_BUS;
import BUS.PhieuDatTiec_BUS;
import BUS.PhieuDichVu_BUS;
import BUS.PhieuHuHai_BUS;
import BUS.PhieuThuePhong_BUS;
import BUS.Phong_BUS;
import DTO.CTPhieuDatPhong_DTO;
import DTO.CTPhieuDatTiec_DTO;
import DTO.CTPhieuDichVu_DTO;
import DTO.CTPhieuThuePhong_DTO;
import DTO.DoanhThuTheoLoaiPhong_DTO;
import DTO.HoaDon_DTO;
import DTO.KhachHang_DTO;
import DTO.PhieuDatPhong_DTO;
import DTO.PhieuDatTiec_DTO;
import DTO.PhieuDichVu_DTO;
import DTO.PhieuHuHai_DTO;
import DTO.PhieuThuePhong_DTO;
import DTO.Phong_DTO;
import java.awt.Menu;
import java.awt.Toolkit;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import net.sf.jasperreports.engine.JRException;

/**
 *
 * @author Lenh Ho Xung
 */
public final class FrameQuanLy extends javax.swing.JFrame {

    //Model cho form đặt phòng   
    DefaultTableModel modelPhongTrong;
    DefaultTableModel modelPhongDat;
    DefaultTableModel modelThongTinKhach;
    //Model cho form thuê phòng
    DefaultTableModel modelKhachDatPhong;
    DefaultTableModel modelPhongDeThue;
    DefaultTableModel modelPhongThue;
    //Model cho form dich vu
    DefaultComboBoxModel cbbModel_dv;
    DefaultTableModel tbModel;
    ArrayList<KhachHang_DTO> ds_dv = new ArrayList<>();
    Vector tableRecords_dv = new Vector();
    Vector tableTitle_dv = new Vector();
    Float thanhTien_dv;
    //Model cho form dat tiec
    DefaultComboBoxModel cbbModel_tiec;
    DefaultTableModel tbModel_tiec;
    ArrayList<KhachHang_DTO> ds_tiec = new ArrayList<>();
    Vector tableTitle_tiec = new Vector();
    Vector tableRecords_tiec = new Vector();
    //Model cho form hoa don
    DefaultTableModel modelChiPhi;
    //Model cho form hu hai
    DefaultComboBoxModel cbbModel_huhai;
    DefaultTableModel modelDs_huhai;
    ArrayList<KhachHang_DTO> ds_huhai;

    /**
     * Creates new form FrameQuanLy
     */
    public FrameQuanLy() {
        initComponents();
        this.setSize(852, 650);
        this.setIconImage(Toolkit.getDefaultToolkit().getImage("src/Image/quanlyphong.png"));
    }

    public void showDSPhongTrong() {
        try {
            modelPhongTrong = Phong_BUS.layDanhSachPhongTrong();
            tablePhongTrong_dat.setModel(modelPhongTrong);
        } catch (Exception e) {
        }
    }

    public void showDSPhongDat() {
        Vector column = new Vector();
        column.add("Mã Phòng");
        column.add("Tên Loại Phòng");
        column.add("Đơn Giá");
        modelPhongDat = new DefaultTableModel(column, 0);
        tablebPhongChon_dat.setModel(modelPhongDat);
    }

    public void showPhongDeThue() {
        try {
            modelPhongDeThue = Phong_BUS.layDanhSachPhongDeThue();
        } catch (Exception ex) {
            Logger.getLogger(PhieuThuePhong.class.getName()).log(Level.SEVERE, null, ex);
        }
        tbPhongTrong_thue.setModel(modelPhongDeThue);
    }

    public void showTablePhongThue() {
        Vector column = new Vector();
        column.add("Mã Phòng");
        column.add("Tên Loại Phòng");
        column.add("Đơn Giá");
        modelPhongThue = new DefaultTableModel(column, 0);
        tbPhongChon_thue.setModel(modelPhongThue);
    }

    protected void showCbbMaKhach_dv() {
        cbbModel_dv = (DefaultComboBoxModel) cbbMaKhach_dv.getModel();
        try {
            ds_dv = KhachHang_BUS.layKhachDangThue();
        } catch (Exception e) {
        }

        for (KhachHang_DTO lp : ds_dv) {
            cbbModel_dv.addElement(lp.getMaKhachHang());
        }
    }

    protected String layMaPhieuDat() {
        String nextID = null;
        try {
            String lastID = PhieuDichVu_BUS.layMaCuoiCung();
            if (lastID != null) {
                nextID = PhieuDichVu_BUS.taoMaTuDong(lastID, 4);
            } else {
                nextID = PhieuDichVu_BUS.taoMaTuDong("MPDV0000", 4);
            }

        } catch (Exception e) {
        }
        return nextID;
    }

    protected void showBangDichVu() {
        try {
            tbModel = DichVu_BUS.layBangDichVu();
            tableDichVu.setModel(tbModel);
        } catch (Exception e) {
        }
    }

    protected String maCTPhieuDichVu() throws Exception {
        String lastID = CTPhieuDichVu_BUS.layMaCuoiCung();
        String nextID = null;
        try {
            if (lastID != null) {
                nextID = CTPhieuDichVu_BUS.taoMaTuDong(lastID, 5);
            } else {
                nextID = CTPhieuDichVu_BUS.taoMaTuDong("MCTDV000000", 5);
            }
        } catch (Exception e) {
        }
        return nextID;
    }

    private Float tinhThanhTien() {
        Float thanhTien = 0f;
        for (int i = 0; i < tablePhieuDatTiec_tiec.getRowCount(); i++) {
            int soLuong = Integer.parseInt(tablePhieuDatTiec_tiec.getValueAt(i, 3).toString());
            Float donGia = Float.parseFloat(tablePhieuDatTiec_tiec.getValueAt(i, 2).toString());
            thanhTien += soLuong * donGia;
        }
        return thanhTien;
    }

    protected void showCbbMaKhach_tiec() {
        cbbModel_tiec = (DefaultComboBoxModel) cbbMaKhach_tiec.getModel();
        try {
            ds_tiec = KhachHang_BUS.layKhachDangThue();
        } catch (Exception e) {
        }

        for (KhachHang_DTO lp : ds_tiec) {
            cbbModel_tiec.addElement(lp.getMaKhachHang());
        }
    }

    protected void showMaPhieuDat_tiec() {
        try {
            String lastID = PhieuDatTiec_BUS.layMaCuoiCung();
            String nextID = null;
            if (lastID != null) {
                nextID = PhieuDatTiec_BUS.taoMaTuDong(lastID, 4);
            } else {
                nextID = PhieuDatTiec_BUS.taoMaTuDong("MPDT0000", 4);
            }
            tfMaPhieuDat_tiec.setText(nextID);
        } catch (Exception e) {
        }
    }

    protected void showBangMonAn() {
        try {
            tbModel_tiec = MonAn_BUS.layBangMonAn();
            tableMonAn_tiec.setModel(tbModel_tiec);
        } catch (Exception e) {
        }
    }

    protected String maCTPhieuDatTiec() throws Exception {
        String lastID = CTPhieuDatTiec_BUS.layMaCuoiCung();
        String nextID = null;
        try {
            if (lastID != null) {
                nextID = CTPhieuDatTiec_BUS.taoMaTuDong(lastID, 4);
            } else {
                nextID = CTPhieuDatTiec_BUS.taoMaTuDong("MCTT000000", 4);
            }
        } catch (Exception e) {
        }
        return nextID;
    }

    protected void showCbbMaKhach_hd() {
        DefaultComboBoxModel cbbModel;
        ArrayList<KhachHang_DTO> ds = new ArrayList<>();
        cbbModel = (DefaultComboBoxModel) cbbMaKhach_hd.getModel();
        try {
            ds = KhachHang_BUS.layKhachDangThue();
        } catch (Exception e) {
        }

        for (KhachHang_DTO lp : ds) {
            cbbModel.addElement(lp.getMaKhachHang());

        }


    }

    public void showTableChiPhi() {
        Vector column = new Vector();
        column.add("Tiền phòng");
        column.add("Tiền dịch vụ");
        column.add("Tiền đặt tiệc");
        column.add("Tiền hư hại");
        modelChiPhi = new DefaultTableModel(column, 0);
        tbCacKhoanPhi.setModel(modelChiPhi);
    }

    protected void showCbbMaKhach_huhai() {
        cbbModel_huhai = (DefaultComboBoxModel) cbbMaKhach_huhai.getModel();
        try {
            ds_huhai = KhachHang_BUS.layKhachDangThue();
        } catch (Exception e) {
        }

        for (KhachHang_DTO lp : ds_huhai) {
            cbbModel_huhai.addElement(lp.getMaKhachHang());
        }
    }

    protected void showDanhSach_huhai() {
        try {
            modelDs_huhai = PhieuHuHai_BUS.layDanhSach();
            tbDanhSach_huhai.setModel(modelDs_huhai);
        } catch (Exception ex) {
            Logger.getLogger(PhieuHuHai.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    public void huyPhieuDatQuaHan() {
        SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
        Date dtoday = new Date(System.currentTimeMillis() - 100742784);
        String today = format.format(dtoday);
        try {
            ArrayList<PhieuDatPhong_DTO> ds = PhieuDatPhong_BUS.layDSMaPhieuDatQuaHan(today);
            for (int i = 0; i < ds.size(); i++) {
                String maPhieuDat = ds.get(i).getMaPhieuDat().toString();
                ArrayList<Phong_DTO> dsmaPhong = new ArrayList<>();
                dsmaPhong = PhieuDatPhong_BUS.layDSMaPhongDat(maPhieuDat);
                for (int j = 0; j < dsmaPhong.size(); j++) {
                    Phong_BUS.capnhattinhtrangDat(dsmaPhong.get(j).getMaPhong().toString(), "Trống");
                }
                CTPhieuDatPhong_BUS.Delete(maPhieuDat);
                PhieuDatPhong_BUS.Delete(maPhieuDat);
            }

        } catch (Exception ex) {
            Logger.getLogger(PhieuThuePhong.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        tpQuanLy = new javax.swing.JTabbedPane();
        pnPhieuDat = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        tfTenKhachHang_dat = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        tfCMND_dat = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        tfTriGia_dat = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        tfemail_dat = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        dpNgayDen_dat = new org.jdesktop.swingx.JXDatePicker();
        jLabel6 = new javax.swing.JLabel();
        dpNgayDi_dat = new org.jdesktop.swingx.JXDatePicker();
        btLapPhieu_dat = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        cbbSoKhach_dat = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        tfSoDienThoai_dat = new javax.swing.JTextField();
        Pannel = new javax.swing.JScrollPane();
        tablePhongTrong_dat = new javax.swing.JTable();
        Pannel2 = new javax.swing.JScrollPane();
        tablebPhongChon_dat = new javax.swing.JTable();
        pnPhieuThue = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tbKhachDatPhong = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        tfTenKhachHang_thue = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        tfCMND_thue = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        tfEmail_thue = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        tfSoDienThoai_thue = new javax.swing.JTextField();
        dpNgayThue_thue = new org.jdesktop.swingx.JXDatePicker();
        jLabel13 = new javax.swing.JLabel();
        btLapPhieu_thue = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        cbbSoKhach_thue = new javax.swing.JComboBox();
        jLabel15 = new javax.swing.JLabel();
        dpNgayTra_thue = new org.jdesktop.swingx.JXDatePicker();
        btInPhieu_thue = new javax.swing.JButton();
        jLabel16 = new javax.swing.JLabel();
        tfTriGia_thue = new javax.swing.JTextField();
        jScrollPane3 = new javax.swing.JScrollPane();
        tbPhongChon_thue = new javax.swing.JTable();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbPhongTrong_thue = new javax.swing.JTable();
        pnDichVu = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        cbbMaKhach_dv = new javax.swing.JComboBox();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        tfTenKhach_dv = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        tfSoDienThoai_dv = new javax.swing.JTextField();
        tfThanhTien_dv = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        dpNgayDat_dv = new org.jdesktop.swingx.JXDatePicker();
        jLabel21 = new javax.swing.JLabel();
        btXacNhan_dv = new javax.swing.JButton();
        btHuy_dv = new javax.swing.JButton();
        btInPhieu_dv = new javax.swing.JButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        tablePhieuDichVu = new org.jdesktop.swingx.JXTable();
        jScrollPane5 = new javax.swing.JScrollPane();
        tableDichVu = new org.jdesktop.swingx.JXTable();
        pnDatTiec = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        cbbMaKhach_tiec = new javax.swing.JComboBox();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        tfTenKhach_tiec = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        tfSoDienThoai_tiec = new javax.swing.JTextField();
        jPanel5 = new javax.swing.JPanel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        tfMaPhieuDat_tiec = new javax.swing.JTextField();
        dpNgayDat_tiec = new org.jdesktop.swingx.JXDatePicker();
        jLabel27 = new javax.swing.JLabel();
        tfThanhTien_tiec = new javax.swing.JTextField();
        btXacNhan_tiec = new javax.swing.JButton();
        btBoMon_tiec = new javax.swing.JButton();
        btInPhieu_tiec = new javax.swing.JButton();
        jScrollPane6 = new javax.swing.JScrollPane();
        tableMonAn_tiec = new org.jdesktop.swingx.JXTable();
        jScrollPane7 = new javax.swing.JScrollPane();
        tablePhieuDatTiec_tiec = new org.jdesktop.swingx.JXTable();
        pannelHuHai = new javax.swing.JPanel();
        jPanel9 = new javax.swing.JPanel();
        cbbMaKhach_huhai = new javax.swing.JComboBox();
        jLabel34 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        tfTenKhach_huhai = new javax.swing.JTextField();
        jLabel36 = new javax.swing.JLabel();
        tfSoDienThoai_huhai = new javax.swing.JTextField();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        tfTriGia = new javax.swing.JTextField();
        btLapPhieu = new javax.swing.JButton();
        jScrollPane9 = new javax.swing.JScrollPane();
        taNoiDungHuHai = new javax.swing.JTextArea();
        btInphieu_hh = new javax.swing.JButton();
        jScrollPane10 = new javax.swing.JScrollPane();
        tbDanhSach_huhai = new javax.swing.JTable();
        pnHoaDon = new javax.swing.JPanel();
        jPanel6 = new javax.swing.JPanel();
        cbbMaKhach_hd = new javax.swing.JComboBox();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        tfTenKhach_hd = new javax.swing.JTextField();
        jLabel30 = new javax.swing.JLabel();
        tfSoDienThoai_hd = new javax.swing.JTextField();
        jLabel31 = new javax.swing.JLabel();
        tfTriGia_hd = new javax.swing.JTextField();
        btLapPhieu_hd = new javax.swing.JButton();
        jLabel32 = new javax.swing.JLabel();
        dpNgayThanhToan_hd = new org.jdesktop.swingx.JXDatePicker();
        btInhoadon = new javax.swing.JButton();
        jScrollPane8 = new javax.swing.JScrollPane();
        tbCacKhoanPhi = new javax.swing.JTable();
        pannelBaoCao = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jLabel33 = new javax.swing.JLabel();
        cbThang = new javax.swing.JComboBox();
        tfNam = new javax.swing.JTextField();
        btLapBaoCao = new javax.swing.JButton();
        jLabel39 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setPreferredSize(new java.awt.Dimension(852, 650));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });
        addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentMoved(java.awt.event.ComponentEvent evt) {
                formComponentMoved(evt);
            }
        });

        tpQuanLy.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                tpQuanLyStateChanged(evt);
            }
        });
        tpQuanLy.addComponentListener(new java.awt.event.ComponentAdapter() {
            public void componentShown(java.awt.event.ComponentEvent evt) {
                tpQuanLyComponentShown(evt);
            }
        });

        pnPhieuDat.setPreferredSize(new java.awt.Dimension(748, 545));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin khách hàng"));
        jPanel1.setName("Thông tin khách hàng"); // NOI18N

        jLabel1.setText("Tên Khách Hàng");

        jLabel2.setText("CMND");

        jLabel3.setText("Số điện thoại");

        tfTriGia_dat.setEditable(false);
        tfTriGia_dat.setBackground(new java.awt.Color(204, 204, 204));

        jLabel4.setText("Email");

        jLabel5.setText("Ngày đến");

        dpNgayDen_dat.setDate(new Date(System.currentTimeMillis()));

        jLabel6.setText("Ngày đi");

        dpNgayDi_dat.setDate(new Date(System.currentTimeMillis()));

        btLapPhieu_dat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Dat.png"))); // NOI18N
        btLapPhieu_dat.setText("Lập Phiếu");
        btLapPhieu_dat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLapPhieu_datActionPerformed(evt);
            }
        });

        jLabel7.setText("Số người:");

        cbbSoKhach_dat.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30" }));

        jLabel8.setText("Trị giá");

        tfSoDienThoai_dat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfSoDienThoai_datActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(68, 68, 68)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel8)
                    .addComponent(jLabel7)
                    .addComponent(jLabel5)
                    .addComponent(jLabel3)
                    .addComponent(jLabel1))
                .addGap(40, 40, 40)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cbbSoKhach_dat, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dpNgayDen_dat, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(tfTenKhachHang_dat)
                    .addComponent(tfTriGia_dat)
                    .addComponent(tfSoDienThoai_dat, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel2)
                                .addComponent(jLabel4))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addGap(5, 5, 5)))
                        .addGap(34, 34, 34)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(tfemail_dat)
                            .addComponent(tfCMND_dat)
                            .addComponent(dpNgayDi_dat, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(179, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btLapPhieu_dat)
                        .addGap(46, 46, 46))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfTenKhachHang_dat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(tfCMND_dat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(tfemail_dat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfSoDienThoai_dat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(dpNgayDen_dat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(dpNgayDi_dat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(cbbSoKhach_dat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(tfTriGia_dat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                        .addComponent(btLapPhieu_dat)
                        .addGap(19, 19, 19))))
        );

        Pannel.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin phòng trống"));

        tablePhongTrong_dat.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        tablePhongTrong_dat.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablePhongTrong_datMouseClicked(evt);
            }
        });
        Pannel.setViewportView(tablePhongTrong_dat);

        Pannel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin phòng chọn"));

        tablebPhongChon_dat.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tablebPhongChon_dat.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablebPhongChon_datMouseClicked(evt);
            }
        });
        Pannel2.setViewportView(tablebPhongChon_dat);

        javax.swing.GroupLayout pnPhieuDatLayout = new javax.swing.GroupLayout(pnPhieuDat);
        pnPhieuDat.setLayout(pnPhieuDatLayout);
        pnPhieuDatLayout.setHorizontalGroup(
            pnPhieuDatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnPhieuDatLayout.createSequentialGroup()
                .addContainerGap(11, Short.MAX_VALUE)
                .addGroup(pnPhieuDatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pnPhieuDatLayout.createSequentialGroup()
                        .addComponent(Pannel, javax.swing.GroupLayout.PREFERRED_SIZE, 430, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(Pannel2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        pnPhieuDatLayout.setVerticalGroup(
            pnPhieuDatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnPhieuDatLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(pnPhieuDatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(Pannel, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
                    .addComponent(Pannel2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap(87, Short.MAX_VALUE))
        );

        tpQuanLy.addTab("Phiếu đặt phòng", new javax.swing.ImageIcon(getClass().getResource("/Image/Thue.png")), pnPhieuDat); // NOI18N

        jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder("Khách đã đặt phòng"));

        tbKhachDatPhong.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        tbKhachDatPhong.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbKhachDatPhongMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tbKhachDatPhong);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin khách"));

        jLabel9.setText("Tên Khách Hàng");

        jLabel10.setText("CMND");

        tfCMND_thue.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                tfCMND_thueKeyTyped(evt);
            }
        });

        jLabel11.setText("Email");

        jLabel12.setText("Số điện thoại");

        dpNgayThue_thue.setDate(new Date(System.currentTimeMillis()));

        jLabel13.setText("Ngày Thuê");

        btLapPhieu_thue.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Dat.png"))); // NOI18N
        btLapPhieu_thue.setText("Lập Phiếu");
        btLapPhieu_thue.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLapPhieu_thueActionPerformed(evt);
            }
        });

        jLabel14.setText("Số khách");

        cbbSoKhach_thue.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30" }));

        jLabel15.setText("Ngày Trả");

        dpNgayTra_thue.setDate(new Date(System.currentTimeMillis()));

        btInPhieu_thue.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/baocao.png"))); // NOI18N
        btInPhieu_thue.setText("In phiếu");
        btInPhieu_thue.setEnabled(false);
        btInPhieu_thue.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btInPhieu_thueActionPerformed(evt);
            }
        });

        jLabel16.setText("Trị Giá");

        tfTriGia_thue.setEditable(false);
        tfTriGia_thue.setBackground(new java.awt.Color(204, 204, 204));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel13)
                            .addComponent(jLabel9)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel14)
                                .addComponent(jLabel15)
                                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(34, 34, 34)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(dpNgayThue_thue, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(tfTenKhachHang_thue, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(cbbSoKhach_thue, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(dpNgayTra_thue, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(tfTriGia_thue, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addGap(34, 34, 34)
                                .addComponent(tfEmail_thue, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel10)
                                .addGap(34, 34, 34)
                                .addComponent(tfCMND_thue, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addGap(34, 34, 34)
                                .addComponent(tfSoDienThoai_thue, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(22, 22, 22))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(btInPhieu_thue)
                        .addGap(18, 18, 18)
                        .addComponent(btLapPhieu_thue)))
                .addContainerGap())
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btInPhieu_thue, btLapPhieu_thue});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(tfTenKhachHang_thue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(tfCMND_thue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tfEmail_thue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(tfSoDienThoai_thue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(dpNgayThue_thue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dpNgayTra_thue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel14)
                    .addComponent(cbbSoKhach_thue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(tfTriGia_thue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 21, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btLapPhieu_thue)
                    .addComponent(btInPhieu_thue))
                .addGap(13, 13, 13))
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btInPhieu_thue, btLapPhieu_thue});

        jScrollPane3.setBorder(javax.swing.BorderFactory.createTitledBorder("Phòng thuê"));

        tbPhongChon_thue.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, java.awt.Color.red));
        tbPhongChon_thue.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tbPhongChon_thue.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbPhongChon_thueMouseClicked(evt);
            }
        });
        jScrollPane3.setViewportView(tbPhongChon_thue);

        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin phòng để thuê"));

        tbPhongTrong_thue.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        tbPhongTrong_thue.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbPhongTrong_thueMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tbPhongTrong_thue);

        javax.swing.GroupLayout pnPhieuThueLayout = new javax.swing.GroupLayout(pnPhieuThue);
        pnPhieuThue.setLayout(pnPhieuThueLayout);
        pnPhieuThueLayout.setHorizontalGroup(
            pnPhieuThueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnPhieuThueLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnPhieuThueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnPhieuThueLayout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 496, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(pnPhieuThueLayout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 425, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(26, 26, 26)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
                .addGap(37, 37, 37))
        );
        pnPhieuThueLayout.setVerticalGroup(
            pnPhieuThueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnPhieuThueLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnPhieuThueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pnPhieuThueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 206, Short.MAX_VALUE)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addGap(82, 82, 82))
        );

        tpQuanLy.addTab("Phiếu thuê phòng", new javax.swing.ImageIcon(getClass().getResource("/Image/Dat.png")), pnPhieuThue); // NOI18N

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin Khách hàng"));
        jPanel3.setToolTipText("");
        jPanel3.setMinimumSize(new java.awt.Dimension(237, 110));
        jPanel3.setName("Thông tin Khách hàng"); // NOI18N

        cbbMaKhach_dv.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbMaKhach_dvItemStateChanged(evt);
            }
        });

        jLabel17.setText("Mã Khách");

        jLabel18.setText("Tên Khách Hàng");

        jLabel19.setText("Số Điện Thoại");

        tfThanhTien_dv.setEditable(false);
        tfThanhTien_dv.setBackground(new java.awt.Color(204, 204, 204));
        tfThanhTien_dv.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tfThanhTien_dv.setText("0");

        jLabel20.setText("Trị giá");

        dpNgayDat_dv.setDate(new Date(System.currentTimeMillis()));

        jLabel21.setText("Ngày Đặt");

        btXacNhan_dv.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Dat.png"))); // NOI18N
        btXacNhan_dv.setText("Lập phiếu");
        btXacNhan_dv.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btXacNhan_dvMouseEntered(evt);
            }
        });
        btXacNhan_dv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btXacNhan_dvActionPerformed(evt);
            }
        });

        btHuy_dv.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Erase.png"))); // NOI18N
        btHuy_dv.setText("Hủy Dịch Vụ");
        btHuy_dv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btHuy_dvActionPerformed(evt);
            }
        });

        btInPhieu_dv.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/baocao.png"))); // NOI18N
        btInPhieu_dv.setText("In phiếu");
        btInPhieu_dv.setEnabled(false);
        btInPhieu_dv.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btInPhieu_dvMouseEntered(evt);
            }
        });
        btInPhieu_dv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btInPhieu_dvActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(13, 13, 13)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel19)
                    .addComponent(jLabel18)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cbbMaKhach_dv, 0, 148, Short.MAX_VALUE)
                    .addComponent(tfTenKhach_dv)
                    .addComponent(tfSoDienThoai_dv))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btXacNhan_dv, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(28, 28, 28)
                        .addComponent(btHuy_dv)
                        .addGap(27, 27, 27))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addGap(34, 34, 34)
                                        .addComponent(jLabel21))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel20)))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(tfThanhTien_dv, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(dpNgayDat_dv, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(51, 51, 51)
                                .addComponent(btInPhieu_dv, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btHuy_dv, btInPhieu_dv, btXacNhan_dv});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbbMaKhach_dv, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17)
                    .addComponent(dpNgayDat_dv, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(tfThanhTien_dv, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel20))
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(tfTenKhach_dv, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel18)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tfSoDienThoai_dv, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel19))
                        .addContainerGap(66, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btHuy_dv)
                            .addComponent(btXacNhan_dv)
                            .addComponent(btInPhieu_dv))
                        .addContainerGap())))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btHuy_dv, btInPhieu_dv, btXacNhan_dv});

        jScrollPane4.setBorder(javax.swing.BorderFactory.createTitledBorder("Dịch vụ đã chọn"));

        tablePhieuDichVu.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane4.setViewportView(tablePhieuDichVu);

        jScrollPane5.setBorder(javax.swing.BorderFactory.createTitledBorder("Dịch vụ"));
        jScrollPane5.setMinimumSize(new java.awt.Dimension(327, 200));
        jScrollPane5.setPreferredSize(new java.awt.Dimension(327, 200));
        jScrollPane5.setRequestFocusEnabled(false);

        tableDichVu.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tableDichVu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableDichVuMouseClicked(evt);
            }
        });
        jScrollPane5.setViewportView(tableDichVu);

        javax.swing.GroupLayout pnDichVuLayout = new javax.swing.GroupLayout(pnDichVu);
        pnDichVu.setLayout(pnDichVuLayout);
        pnDichVuLayout.setHorizontalGroup(
            pnDichVuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnDichVuLayout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addGroup(pnDichVuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(pnDichVuLayout.createSequentialGroup()
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(27, 27, 27)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 371, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(44, Short.MAX_VALUE))
        );
        pnDichVuLayout.setVerticalGroup(
            pnDichVuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnDichVuLayout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(29, 29, 29)
                .addGroup(pnDichVuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap(100, Short.MAX_VALUE))
        );

        tpQuanLy.addTab("Phiếu dịch vụ", new javax.swing.ImageIcon(getClass().getResource("/Image/DichVu.png")), pnDichVu); // NOI18N

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin Khách hàng"));
        jPanel4.setToolTipText("");
        jPanel4.setName("Thông tin Khách hàng"); // NOI18N
        jPanel4.setPreferredSize(new java.awt.Dimension(237, 110));

        cbbMaKhach_tiec.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbMaKhach_tiecItemStateChanged(evt);
            }
        });
        cbbMaKhach_tiec.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbbMaKhach_tiecActionPerformed(evt);
            }
        });

        jLabel22.setText("Mã Khách");

        jLabel23.setText("Tên Khách Hàng");

        jLabel24.setText("Số Điện Thoại");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel24, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel23, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel22, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tfSoDienThoai_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbbMaKhach_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfTenKhach_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(58, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel22)
                    .addComponent(cbbMaKhach_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(tfTenKhach_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel24)
                    .addComponent(tfSoDienThoai_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(40, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin Phiếu đặt tiệc"));
        jPanel5.setPreferredSize(new java.awt.Dimension(450, 110));

        jLabel25.setText("Mã Phiếu Đặt");

        jLabel26.setText("Ngày Đặt");

        tfMaPhieuDat_tiec.setEditable(false);
        tfMaPhieuDat_tiec.setBackground(new java.awt.Color(204, 204, 204));
        tfMaPhieuDat_tiec.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tfMaPhieuDat_tiec.setMaximumSize(new java.awt.Dimension(12, 20));
        tfMaPhieuDat_tiec.setMinimumSize(new java.awt.Dimension(12, 20));

        dpNgayDat_tiec.setDate(new Date(System.currentTimeMillis()));
        dpNgayDat_tiec.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dpNgayDat_tiecActionPerformed(evt);
            }
        });

        jLabel27.setText("Thành Tiền");

        tfThanhTien_tiec.setEditable(false);
        tfThanhTien_tiec.setBackground(new java.awt.Color(204, 204, 204));
        tfThanhTien_tiec.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        tfThanhTien_tiec.setText("0");
        tfThanhTien_tiec.setMaximumSize(new java.awt.Dimension(12, 20));
        tfThanhTien_tiec.setMinimumSize(new java.awt.Dimension(12, 20));

        btXacNhan_tiec.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Dat.png"))); // NOI18N
        btXacNhan_tiec.setText("Lập phiếu");
        btXacNhan_tiec.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btXacNhan_tiecMouseEntered(evt);
            }
        });
        btXacNhan_tiec.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btXacNhan_tiecActionPerformed(evt);
            }
        });

        btBoMon_tiec.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Erase.png"))); // NOI18N
        btBoMon_tiec.setText("Bỏ Món");
        btBoMon_tiec.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btBoMon_tiecActionPerformed(evt);
            }
        });

        btInPhieu_tiec.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/baocao.png"))); // NOI18N
        btInPhieu_tiec.setText("In Phiếu");
        btInPhieu_tiec.setEnabled(false);
        btInPhieu_tiec.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                btInPhieu_tiecMouseEntered(evt);
            }
        });
        btInPhieu_tiec.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btInPhieu_tiecActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(2, 2, 2)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel25, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel27, javax.swing.GroupLayout.Alignment.TRAILING))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(tfMaPhieuDat_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel26)
                        .addGap(18, 18, 18)
                        .addComponent(dpNgayDat_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(tfThanhTien_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(60, 60, 60))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btInPhieu_tiec)
                .addGap(18, 18, 18)
                .addComponent(btXacNhan_tiec)
                .addGap(18, 18, 18)
                .addComponent(btBoMon_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27))
        );

        jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btBoMon_tiec, btXacNhan_tiec});

        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel25)
                    .addComponent(tfMaPhieuDat_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel26)
                    .addComponent(dpNgayDat_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel27)
                    .addComponent(tfThanhTien_tiec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btXacNhan_tiec)
                    .addComponent(btBoMon_tiec)
                    .addComponent(btInPhieu_tiec))
                .addContainerGap())
        );

        jPanel5Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {btBoMon_tiec, btXacNhan_tiec});

        jScrollPane6.setBorder(javax.swing.BorderFactory.createTitledBorder("Món ăn"));

        tableMonAn_tiec.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tableMonAn_tiec.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableMonAn_tiecMouseClicked(evt);
            }
        });
        jScrollPane6.setViewportView(tableMonAn_tiec);

        jScrollPane7.setBorder(javax.swing.BorderFactory.createTitledBorder("Chi tiết Phiếu đăt tiệc"));

        tablePhieuDatTiec_tiec.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tablePhieuDatTiec_tiec.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tablePhieuDatTiec_tiecMouseClicked(evt);
            }
        });
        jScrollPane7.setViewportView(tablePhieuDatTiec_tiec);

        javax.swing.GroupLayout pnDatTiecLayout = new javax.swing.GroupLayout(pnDatTiec);
        pnDatTiec.setLayout(pnDatTiecLayout);
        pnDatTiecLayout.setHorizontalGroup(
            pnDatTiecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnDatTiecLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(pnDatTiecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 365, Short.MAX_VALUE)
                    .addComponent(jScrollPane6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnDatTiecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 440, Short.MAX_VALUE)
                    .addComponent(jScrollPane7))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnDatTiecLayout.setVerticalGroup(
            pnDatTiecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnDatTiecLayout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(pnDatTiecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnDatTiecLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 382, Short.MAX_VALUE)
                    .addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap(78, Short.MAX_VALUE))
        );

        tpQuanLy.addTab("Phiếu đặt tiệc", new javax.swing.ImageIcon(getClass().getResource("/Image/Dattiec.png")), pnDatTiec); // NOI18N

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin Khách hàng"));
        jPanel9.setToolTipText("");
        jPanel9.setName("Thông tin Khách hàng"); // NOI18N
        jPanel9.setPreferredSize(new java.awt.Dimension(237, 110));

        cbbMaKhach_huhai.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbMaKhach_huhaiItemStateChanged(evt);
            }
        });
        cbbMaKhach_huhai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbbMaKhach_huhaiActionPerformed(evt);
            }
        });

        jLabel34.setText("Mã Khách");

        jLabel35.setText("Tên Khách Hàng");

        tfTenKhach_huhai.setEditable(false);

        jLabel36.setText("Số Điện Thoại");

        tfSoDienThoai_huhai.setEditable(false);

        jLabel37.setText("Nội dung hư hại: ");

        jLabel38.setText("Trị Giá:");

        btLapPhieu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Dat.png"))); // NOI18N
        btLapPhieu.setText("Lập phiếu");
        btLapPhieu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLapPhieuActionPerformed(evt);
            }
        });

        taNoiDungHuHai.setColumns(20);
        taNoiDungHuHai.setFont(new java.awt.Font("Times New Roman", 0, 12)); // NOI18N
        taNoiDungHuHai.setRows(5);
        jScrollPane9.setViewportView(taNoiDungHuHai);

        btInphieu_hh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/baocao.png"))); // NOI18N
        btInphieu_hh.setText("In phiếu");
        btInphieu_hh.setEnabled(false);
        btInphieu_hh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btInphieu_hhActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGap(32, 32, 32)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGap(61, 61, 61)
                        .addComponent(jLabel38)
                        .addGap(4, 4, 4)
                        .addComponent(tfTriGia, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addComponent(jLabel35)
                                .addGap(18, 18, 18)
                                .addComponent(tfTenKhach_huhai, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addComponent(jLabel34)
                                .addGap(18, 18, 18)
                                .addComponent(cbbMaKhach_huhai, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                .addComponent(jLabel37)
                                .addGap(141, 141, 141)))
                        .addGap(52, 52, 52)
                        .addComponent(jLabel36)
                        .addGap(27, 27, 27)
                        .addComponent(tfSoDienThoai_huhai, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGap(100, 100, 100)
                        .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 264, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(43, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btInphieu_hh)
                .addGap(31, 31, 31)
                .addComponent(btLapPhieu)
                .addGap(62, 62, 62))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel34)
                            .addComponent(cbbMaKhach_huhai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tfTenKhach_huhai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel35)
                            .addComponent(jLabel36)))
                    .addComponent(tfSoDienThoai_huhai, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel9Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel37)))
                .addGap(18, 18, 18)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel38)
                    .addComponent(tfTriGia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btLapPhieu)
                    .addComponent(btInphieu_hh))
                .addContainerGap(28, Short.MAX_VALUE))
        );

        jScrollPane10.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        tbDanhSach_huhai.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane10.setViewportView(tbDanhSach_huhai);

        javax.swing.GroupLayout pannelHuHaiLayout = new javax.swing.GroupLayout(pannelHuHai);
        pannelHuHai.setLayout(pannelHuHaiLayout);
        pannelHuHaiLayout.setHorizontalGroup(
            pannelHuHaiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pannelHuHaiLayout.createSequentialGroup()
                .addGroup(pannelHuHaiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pannelHuHaiLayout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 774, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pannelHuHaiLayout.createSequentialGroup()
                        .addGap(111, 111, 111)
                        .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, 578, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(32, Short.MAX_VALUE))
        );
        pannelHuHaiLayout.setVerticalGroup(
            pannelHuHaiLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pannelHuHaiLayout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, 279, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane10, javax.swing.GroupLayout.PREFERRED_SIZE, 266, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(48, 48, 48))
        );

        tpQuanLy.addTab("Phiếu hư hại", new javax.swing.ImageIcon(getClass().getResource("/Image/LoaiPhong.png")), pannelHuHai); // NOI18N

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("Thông tin Khách hàng"));
        jPanel6.setToolTipText("");
        jPanel6.setName("Thông tin Khách hàng"); // NOI18N
        jPanel6.setPreferredSize(new java.awt.Dimension(237, 110));

        cbbMaKhach_hd.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbbMaKhach_hdItemStateChanged(evt);
            }
        });
        cbbMaKhach_hd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbbMaKhach_hdActionPerformed(evt);
            }
        });

        jLabel28.setText("Mã Khách");

        jLabel29.setText("Tên Khách Hàng");

        tfTenKhach_hd.setEditable(false);

        jLabel30.setText("Số Điện Thoại");

        tfSoDienThoai_hd.setEditable(false);

        jLabel31.setText("Trị Giá:");

        tfTriGia_hd.setEditable(false);

        btLapPhieu_hd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Dat.png"))); // NOI18N
        btLapPhieu_hd.setText("Lập hóa đơn");
        btLapPhieu_hd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLapPhieu_hdActionPerformed(evt);
            }
        });

        jLabel32.setText("Ngày Thanh Toán");

        dpNgayThanhToan_hd.setDate(new Date (System.currentTimeMillis()));

        btInhoadon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/baocao.png"))); // NOI18N
        btInhoadon.setText("In hóa đơn");
        btInhoadon.setEnabled(false);
        btInhoadon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btInhoadonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel32)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(dpNgayThanhToan_hd, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(67, 67, 67)
                        .addComponent(jLabel31))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addComponent(jLabel29)
                                .addGap(18, 18, 18)
                                .addComponent(tfTenKhach_hd, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                .addComponent(jLabel28)
                                .addGap(18, 18, 18)
                                .addComponent(cbbMaKhach_hd, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel30)))
                .addGap(27, 27, 27)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tfSoDienThoai_hd, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfTriGia_hd, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(209, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btInhoadon)
                .addGap(35, 35, 35)
                .addComponent(btLapPhieu_hd)
                .addGap(32, 32, 32))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(tfSoDienThoai_hd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel30))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel28)
                            .addComponent(cbbMaKhach_hd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(tfTenKhach_hd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel29))))
                .addGap(18, 18, 18)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel32)
                    .addComponent(dpNgayThanhToan_hd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfTriGia_hd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel31))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 31, Short.MAX_VALUE)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btLapPhieu_hd)
                    .addComponent(btInhoadon))
                .addGap(20, 20, 20))
        );

        jScrollPane8.setBorder(javax.swing.BorderFactory.createTitledBorder("Các khoản phí"));

        tbCacKhoanPhi.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane8.setViewportView(tbCacKhoanPhi);

        javax.swing.GroupLayout pnHoaDonLayout = new javax.swing.GroupLayout(pnHoaDon);
        pnHoaDon.setLayout(pnHoaDonLayout);
        pnHoaDonLayout.setHorizontalGroup(
            pnHoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnHoaDonLayout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addGroup(pnHoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane8)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, 744, Short.MAX_VALUE))
                .addContainerGap(45, Short.MAX_VALUE))
        );
        pnHoaDonLayout.setVerticalGroup(
            pnHoaDonLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnHoaDonLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 389, Short.MAX_VALUE)
                .addContainerGap())
        );

        tpQuanLy.addTab("Hóa đơn", new javax.swing.ImageIcon(getClass().getResource("/Image/HoaDon.png")), pnHoaDon); // NOI18N

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel33.setText("Tháng ");

        cbThang.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));

        btLapBaoCao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/baocao.png"))); // NOI18N
        btLapBaoCao.setText("Lập Báo Cáo");
        btLapBaoCao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLapBaoCaoActionPerformed(evt);
            }
        });

        jLabel39.setText("Năm");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btLapBaoCao)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jLabel33)
                        .addGap(18, 18, 18)
                        .addComponent(cbThang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel39)
                        .addGap(18, 18, 18)
                        .addComponent(tfNam, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cbThang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tfNam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel33)
                    .addComponent(jLabel39))
                .addGap(18, 18, 18)
                .addComponent(btLapBaoCao)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout pannelBaoCaoLayout = new javax.swing.GroupLayout(pannelBaoCao);
        pannelBaoCao.setLayout(pannelBaoCaoLayout);
        pannelBaoCaoLayout.setHorizontalGroup(
            pannelBaoCaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pannelBaoCaoLayout.createSequentialGroup()
                .addContainerGap(317, Short.MAX_VALUE)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(259, 259, 259))
        );
        pannelBaoCaoLayout.setVerticalGroup(
            pannelBaoCaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pannelBaoCaoLayout.createSequentialGroup()
                .addGap(126, 126, 126)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(389, Short.MAX_VALUE))
        );

        tpQuanLy.addTab("Báo cáo doanh thu", new javax.swing.ImageIcon(getClass().getResource("/Image/Thue.png")), pannelBaoCao); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(tpQuanLy, javax.swing.GroupLayout.PREFERRED_SIZE, 836, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(tpQuanLy)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
        FrameMenu.menu.setEnabled(true);
    }//GEN-LAST:event_formWindowClosing

    private void btLapPhieu_datActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLapPhieu_datActionPerformed
        // TODO add your handling code here:

        //Them khach hang
        String makhach;
        String makhachmax;
        try {
            makhachmax = KhachHang_BUS.laymaMax();
            if (makhachmax.equals("")) {
                makhach = Phong_BUS.taoMaTuDong("MK000000", 2);

            } else {
                makhach = Phong_BUS.taoMaTuDong(makhachmax, 2);
            }
            String tenKhach = tfTenKhachHang_dat.getText();
            String sdt = tfSoDienThoai_dat.getText();
            String email = tfemail_dat.getText();
            String CMND = tfCMND_dat.getText();
            String tinhtrang = "Đang đặt";
            if (CMND.equals("")) {
                JOptionPane.showMessageDialog(rootPane, "Bạn phải nhập CMND (Hộ chiếu) của khách!");
                return;
            }

            //them phieudat
            int row = tablebPhongChon_dat.getRowCount();
            if (row <= 0) {
                JOptionPane.showMessageDialog(rootPane, "Bạn phải chọn phòng cho khách!");
                return;
            }
            String maphieu;
            String maphieumax;
            maphieumax = PhieuDatPhong_BUS.laymaMax();
            if (maphieumax.equals("")) {
                maphieu = Phong_BUS.taoMaTuDong("MPD000000", 3);

            } else {
                maphieu = Phong_BUS.taoMaTuDong(maphieumax, 3);

            }
            String sokhach = cbbSoKhach_dat.getSelectedItem().toString();
            SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");

            Date dngayden = dpNgayDen_dat.getDate();
            Date dngaydi = dpNgayDi_dat.getDate();
            Date today = new Date(System.currentTimeMillis() - 100742784);
            String ngayden = format.format(dngayden);
            String ngaydi = format.format(dngaydi);

            int sosanh = dngayden.compareTo(today);
            if (sosanh < 0) {
                JOptionPane.showMessageDialog(rootPane, "Ngày đến phải bằng hoặc sau hiện tại!");
                return;
            }
            if (dngaydi.before(dngayden)) {
                JOptionPane.showMessageDialog(rootPane, "Ngày đi phải lớn hơn hoặc bằng ngày đến!");
                return;
            }

            float dongia = 0;
            for (int i = 0; i < row; i++) {
                dongia += Float.parseFloat(tablebPhongChon_dat.getValueAt(i, 2).toString());
            }
            long songaythue = (dngaydi.getTime() - dngayden.getTime()) / 86400000 + 1;
            long trigia = (long) dongia * songaythue;
            tfTriGia_dat.setText(Long.toString(trigia));

            KhachHang_DTO kh = new KhachHang_DTO();
            kh.setMaKhachHang(makhach);
            kh.setTenKhachHang(tenKhach);
            kh.setCmnd(CMND);
            kh.setDienThoai(sdt);
            kh.setEmail(email);
            kh.setTinhTrang(tinhtrang);
            KhachHang_BUS.Insert(kh);

            PhieuDatPhong_DTO p = new PhieuDatPhong_DTO();
            p.setMaPhieuDat(maphieu);
            p.setMaKhach(makhach);
            p.setNgayden(ngayden);
            p.setNgaydi(ngaydi);
            p.setSoKhach(sokhach);
            p.setTrigia(tfTriGia_dat.getText());

            PhieuDatPhong_BUS.Insert(p);



            //them ct phieu dat
            String mactphieu;
            String mactphieumax;

            for (int i = 0; i < row; i++) {
                mactphieumax = CTPhieuDatPhong_BUS.laymaMax();
                if (mactphieumax.equals("")) {
                    mactphieu = Phong_BUS.taoMaTuDong("MCTPD000000", 5);

                } else {
                    mactphieu = Phong_BUS.taoMaTuDong(mactphieumax, 5);
                }
                CTPhieuDatPhong_DTO ct = new CTPhieuDatPhong_DTO();
                ct.setMaCTPhieuDat(mactphieu);
                ct.setMaPhieuDat(maphieu);
                ct.setMaPhong(tablebPhongChon_dat.getValueAt(i, 0).toString());
                Phong_BUS.capnhattinhtrangDat(tablebPhongChon_dat.getValueAt(i, 0).toString(), "Đang đặt");
                CTPhieuDatPhong_BUS.Insert(ct);
            }
            JOptionPane.showMessageDialog(rootPane, "Lập phiếu thành công!");
            tfTenKhachHang_dat.setText("");
            tfCMND_dat.setText("");
            tfSoDienThoai_dat.setText("");
            tfemail_dat.setText("");
            tfTriGia_dat.setText("");
            modelPhongDat.setNumRows(0);
        } catch (Exception e) {
        }
    }//GEN-LAST:event_btLapPhieu_datActionPerformed

    private void tfSoDienThoai_datActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tfSoDienThoai_datActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tfSoDienThoai_datActionPerformed

    private void tablePhongTrong_datMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablePhongTrong_datMouseClicked
        // TODO add your handling code here:
        int row = tablePhongTrong_dat.getSelectedRow();
        Vector rowData = new Vector();
        String maPhong = (String) this.modelPhongTrong.getValueAt(row, 0).toString();
        String tenLoaiPhong = (String) this.modelPhongTrong.getValueAt(row, 1).toString();
        String donGia = (String) this.modelPhongTrong.getValueAt(row, 2).toString();
        rowData.add(maPhong);
        rowData.add(tenLoaiPhong);
        rowData.add(donGia);
        modelPhongDat.addRow(rowData);
        tablebPhongChon_dat.setModel(modelPhongDat);
        modelPhongTrong.removeRow(row);
    }//GEN-LAST:event_tablePhongTrong_datMouseClicked

    private void tbKhachDatPhongMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbKhachDatPhongMouseClicked
        // TODO add your handling code here:
        int row = tbKhachDatPhong.getSelectedRow();
        tfTenKhachHang_thue.setText(tbKhachDatPhong.getValueAt(row, 1).toString());
        tfCMND_thue.setText(tbKhachDatPhong.getValueAt(row, 2).toString());
        tfEmail_thue.setText(tbKhachDatPhong.getValueAt(row, 3).toString());
        tfSoDienThoai_thue.setText(tbKhachDatPhong.getValueAt(row, 4).toString());
        tfTriGia_thue.setText(tbKhachDatPhong.getValueAt(row, 5).toString());
    }//GEN-LAST:event_tbKhachDatPhongMouseClicked

    private void tfCMND_thueKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tfCMND_thueKeyTyped
        // TODO add your handling code here:
        try {
            modelKhachDatPhong = KhachHang_BUS.laykhachDatPhong(tfCMND_thue.getText());
        } catch (Exception ex) {
            Logger.getLogger(PhieuThuePhong.class.getName()).log(Level.SEVERE, null, ex);
        }
        tbKhachDatPhong.setModel(modelKhachDatPhong);

    }//GEN-LAST:event_tfCMND_thueKeyTyped

    private void themBangDoanhThu(String maP, String doanhThu) throws Exception {
        SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy");
        Date ngayHienTai = new Date(System.currentTimeMillis());
        String ngayHT = format.format(ngayHienTai);
        String thangHienTai = ngayHT.substring(3);
        //String[] xyz = ngayHT.split("-");
        //String thangHienTai = xyz[1] + "-" + xyz[2];
        String maDT;
        maDT = DoanhThuTheoLoaiPhong_BUS.layMaDT(maP, thangHienTai);
        System.out.println(maDT);
        if (maDT.equals("")) {
            DoanhThuTheoLoaiPhong_DTO dt = new DoanhThuTheoLoaiPhong_DTO();
            dt.setMaDT(maDoanhThu());
            dt.setThangNam(thangHienTai);
            dt.setMaLoaiPhong(Phong_BUS.layMaLPTheoMP(maP));
            dt.setDoanhThu(doanhThu);
            DoanhThuTheoLoaiPhong_BUS.Insert(dt);
        } else {
            Float doanhThuCu = DoanhThuTheoLoaiPhong_BUS.layDoanhThuTheoThangVaLoaiPhong(thangHienTai, Phong_BUS.layMaLPTheoMP(maP));
            Float doanhThuMoi = Float.parseFloat(doanhThu) + doanhThuCu;
            //dt.setDoanhThu(doanhThuMoi.toString());
            DoanhThuTheoLoaiPhong_BUS.UpdateDoanhThu(doanhThuMoi.toString(), maDT);
        }
    }

    protected String maDoanhThu() throws Exception {
        String lastID = DoanhThuTheoLoaiPhong_BUS.layMaCuoiCung();
        String nextID = null;
        try {
            if (lastID != null) {
                nextID = DoanhThuTheoLoaiPhong_BUS.taoMaTuDong(lastID, 3);
            } else {
                nextID = DoanhThuTheoLoaiPhong_BUS.taoMaTuDong("MDT0000", 3);
            }
        } catch (Exception e) {
        }
        return nextID;
    }
    private void btLapPhieu_thueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLapPhieu_thueActionPerformed
        // TODO add your handling code here:
        //Kiểm tra ô nhập cmnd có được nhập không
        String CMND = tfCMND_thue.getText();
        if (CMND.equals("")) {
            JOptionPane.showMessageDialog(rootPane, "Bạn phải nhập CMND!");
            return;
        }
        //kiểm tra khách hàng có phải đã đặt phòng không
        int rows = tbKhachDatPhong.getRowCount();

        int row = tbKhachDatPhong.getSelectedRow();
        if (rows != 0) {
            String maphieuthueMax;
            String maphieuThue;
            try {
                maphieuthueMax = PhieuThuePhong_BUS.laymaMax();
                if (maphieuthueMax.equals("")) {
                    maphieuThue = Phong_BUS.taoMaTuDong("MPT000000", 3);
                } else {
                    maphieuThue = Phong_BUS.taoMaTuDong(maphieuthueMax, 3);
                }
                String maKhach = tbKhachDatPhong.getValueAt(row, 0).toString();

                SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
                Date dngayden = dpNgayThue_thue.getDate();
                Date dngaytra = dpNgayTra_thue.getDate();
                String ngaythue = format.format(dngayden);
                String ngaytra = format.format(dngaytra);
                String soKhach = cbbSoKhach_thue.getSelectedItem().toString();

                if (dngaytra.before(dngayden)) {
                    JOptionPane.showMessageDialog(rootPane, "Ngày đi phải lớn hơn hoặc bằng ngày đến!");
                    return;
                }
                //Them CT PhieuThue

                String mactphieumax;
                String mactPhieu;

                int row_chon = tbPhongChon_thue.getRowCount();
                if (row_chon <= 0) {
                    JOptionPane.showMessageDialog(rootPane, "Bạn phải chọn phòng cho khách!");
                    return;
                }

                Float dongia;
                long songaythue = (dngaytra.getTime() - dngayden.getTime()) / 86400000 + 1;
                Float trigia;
                long tongtrigia = 0;
                for (int i = 0; i < row_chon; i++) {
                    dongia = Float.parseFloat(tbPhongChon_thue.getValueAt(i, 2).toString());
                    trigia = dongia * songaythue;
                    String maP = (String) tbPhongChon_thue.getValueAt(i, 0);
                    themBangDoanhThu(maP, trigia.toString());
                    tongtrigia += trigia;
                }
                //long tongtrigia = (long) dongia * songaythue;
                tfTriGia_thue.setText(Long.toString(tongtrigia));
                PhieuThuePhong_DTO p = new PhieuThuePhong_DTO();
                p.setMaphieuThue(maphieuThue);
                p.setMaKhach(maKhach);
                p.setNgayThue(ngaythue);
                p.setNgayTra(ngaytra);
                p.setSoKhach(soKhach);
                p.setTriGia(tfTriGia_thue.getText());
                KhachHang_BUS.capNhatTinhTrangKhach(maKhach, "Đang thuê");
                PhieuThuePhong_BUS.Insert(p);
                for (int i = 0; i < row_chon; i++) {
                    mactphieumax = CTPhieuThuePhong_BUS.laymaMax();
                    if (mactphieumax.equals("")) {
                        mactPhieu = Phong_BUS.taoMaTuDong("MCTPT000000", 5);
                    } else {
                        mactPhieu = Phong_BUS.taoMaTuDong(mactphieumax, 5);
                    }
                    String maPhong = tbPhongChon_thue.getValueAt(i, 0).toString();
                    CTPhieuThuePhong_DTO ct = new CTPhieuThuePhong_DTO();
                    ct.setMactphieuThue(mactPhieu);
                    ct.setMaphieuThue(maphieuThue);
                    ct.setMaPhong(maPhong);
                    CTPhieuThuePhong_BUS.Insert(ct);
                    Phong_BUS.capnhattinhtrangDat(maPhong, "Đang thuê");
                }
                String maphieudat = PhieuDatPhong_BUS.layMaPhieuDat(maKhach);
                CTPhieuDatPhong_BUS.Delete(maphieudat);
                PhieuDatPhong_BUS.Delete(maphieudat);
                tbKhachDatPhong.setModel(modelKhachDatPhong);
                JOptionPane.showMessageDialog(rootPane, "Lập phiếu thành công!");



            } catch (Exception ex) {
                Logger.getLogger(PhieuThuePhong.class.getName()).log(Level.SEVERE, null, ex);
            }

            //nếu khách hàng chưa đặt phòng mà còn phòng thì cho thuê mới
        } else {
            String makhach;
            String makhachmax;
            try {
                makhachmax = KhachHang_BUS.laymaMax();
                if (makhachmax.equals("")) {
                    makhach = Phong_BUS.taoMaTuDong("MK000000", 2);
                } else {
                    makhach = Phong_BUS.taoMaTuDong(makhachmax, 2);
                }
                String tenKhach = tfTenKhachHang_dat.getText();
                String sdt = tfSoDienThoai_dat.getText();
                String email = tfEmail_thue.getText();
                String tinhtrang = "Đang thuê";

                String maphieuthueMax;
                String maphieuThue;

                maphieuthueMax = PhieuThuePhong_BUS.laymaMax();
                if (maphieuthueMax.equals("")) {
                    maphieuThue = Phong_BUS.taoMaTuDong("MPT000000", 3);
                } else {
                    maphieuThue = Phong_BUS.taoMaTuDong(maphieuthueMax, 3);
                }

                SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
                Date dngayden = dpNgayThue_thue.getDate();
                String ngaythue = format.format(dngayden);
                Date dngaytra = dpNgayTra_thue.getDate();
                String ngaytra = format.format(dngaytra);
                String soKhach = cbbSoKhach_dat.getSelectedItem().toString();

                if (dngaytra.before(dngayden)) {
                    JOptionPane.showMessageDialog(rootPane, "Ngày đi phải lớn hơn hoặc bằng ngày đến!");
                    return;
                }

                int row_chon = tbPhongChon_thue.getRowCount();
                if (row_chon <= 0) {
                    JOptionPane.showMessageDialog(rootPane, "Bạn phải chọn phòng cho khách!");
                    return;
                }
                float dongia;
                long songaythue = (dngaytra.getTime() - dngayden.getTime()) / 86400000 + 1;
                Float trigia;
                long tongtrigia = 0;
                for (int i = 0; i < row_chon; i++) {
                    //dongia += Float.parseFloat(tbPhongChon_thue.getValueAt(i, 2).toString());
                    dongia = Float.parseFloat(tbPhongChon_thue.getValueAt(i, 2).toString());
                    trigia = dongia * songaythue;
                    String maP = (String) tbPhongChon_thue.getValueAt(i, 0);
                    themBangDoanhThu(maP, trigia.toString());
                    tongtrigia += trigia;
                }
                //long trigia = (long) dongia * songaythue;
                tfTriGia_thue.setText(Long.toString(tongtrigia));

                KhachHang_DTO kh = new KhachHang_DTO();
                kh.setMaKhachHang(makhach);
                kh.setTenKhachHang(tenKhach);
                kh.setCmnd(CMND);
                kh.setDienThoai(sdt);
                kh.setEmail(email);
                kh.setTinhTrang(tinhtrang);
                KhachHang_BUS.Insert(kh);

                PhieuThuePhong_DTO p = new PhieuThuePhong_DTO();
                p.setMaphieuThue(maphieuThue);
                p.setMaKhach(makhach);
                p.setNgayThue(ngaythue);
                p.setNgayTra(ngaytra);
                p.setSoKhach(soKhach);
                p.setTriGia(tfTriGia_thue.getText());
                PhieuThuePhong_BUS.Insert(p);

                String mactphieumax;
                String mactPhieu;
                for (int i = 0; i < row_chon; i++) {
                    mactphieumax = CTPhieuThuePhong_BUS.laymaMax();
                    if (mactphieumax.equals("")) {
                        mactPhieu = Phong_BUS.taoMaTuDong("MCTPT000000", 5);
                    } else {
                        mactPhieu = Phong_BUS.taoMaTuDong(mactphieumax, 5);
                    }
                    String maPhong = tbPhongChon_thue.getValueAt(i, 0).toString();
                    CTPhieuThuePhong_DTO ct = new CTPhieuThuePhong_DTO();
                    ct.setMactphieuThue(mactPhieu);
                    ct.setMaphieuThue(maphieuThue);
                    ct.setMaPhong(maPhong);
                    CTPhieuThuePhong_BUS.Insert(ct);
                    Phong_BUS.capnhattinhtrangDat(maPhong, "Đang thuê");

                }
                JOptionPane.showMessageDialog(rootPane, "Lập phiếu thành công!");

            } catch (Exception ex) {
                Logger.getLogger(PhieuThuePhong.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
        btInPhieu_thue.setEnabled(true);
        
    }//GEN-LAST:event_btLapPhieu_thueActionPerformed

    private void btInPhieu_thueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInPhieu_thueActionPerformed
        // TODO add your handling code here:
        int rows = tbKhachDatPhong.getRowCount();

        int row = tbKhachDatPhong.getSelectedRow();
        if (rows != 0) {
            String maKhach = tbKhachDatPhong.getValueAt(row, 0).toString();
            try {
                new ShowReport().Show_ReportPhieuThue(maKhach);
                modelPhongThue.setNumRows(0);
                modelKhachDatPhong.setNumRows(0);
                tfTenKhachHang_thue.setText("");
                tfCMND_thue.setText("");
                tfSoDienThoai_thue.setText("");
                tfEmail_thue.setText("");
                tfTriGia_thue.setText("");
            } catch (JRException ex) {
                Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
            } catch (ClassNotFoundException ex) {
                Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SQLException ex) {
                Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
            } catch (Exception ex) {
                Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
            }

        } else {
            String makhach;

            try {
                makhach = KhachHang_BUS.laymaMax();
                new ShowReport().Show_ReportPhieuThue(makhach);
                modelPhongThue.setNumRows(0);
                modelKhachDatPhong.setNumRows(0);
                tfTenKhachHang_thue.setText("");
                tfCMND_thue.setText("");
                tfSoDienThoai_thue.setText("");
                tfEmail_thue.setText("");
                tfTriGia_thue.setText("");

            } catch (Exception ex) {
                Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        btInPhieu_thue.setEnabled(false);

    }//GEN-LAST:event_btInPhieu_thueActionPerformed

    private void tbPhongTrong_thueMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbPhongTrong_thueMouseClicked
        // TODO add your handling code here:
        int row = tbPhongTrong_thue.getSelectedRow();
        Vector rowData = new Vector();
        String maPhong = (String) this.modelPhongDeThue.getValueAt(row, 0).toString();
        String tenLoaiPhong = (String) this.modelPhongDeThue.getValueAt(row, 1).toString();
        String donGia = (String) this.modelPhongDeThue.getValueAt(row, 2).toString();
        rowData.add(maPhong);
        rowData.add(tenLoaiPhong);
        rowData.add(donGia);
        modelPhongThue.addRow(rowData);
        tbPhongChon_thue.setModel(modelPhongThue);
        modelPhongDeThue.removeRow(row);
    }//GEN-LAST:event_tbPhongTrong_thueMouseClicked

    private void cbbMaKhach_dvItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbMaKhach_dvItemStateChanged
        try {
            // TODO add your handling code here:
            tfTenKhach_dv.setText(KhachHang_BUS.layTenKHTheoMa(cbbMaKhach_dv.getSelectedItem().toString()));
        } catch (Exception ex) {
            Logger.getLogger(PhieuDatTiec.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            // TODO add your handling code here:
            tfSoDienThoai_dat.setText(KhachHang_BUS.laySoDTTheoMa(cbbMaKhach_dv.getSelectedItem().toString()));
        } catch (Exception ex) {
            Logger.getLogger(PhieuDatTiec.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_cbbMaKhach_dvItemStateChanged

    private void btXacNhan_dvMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btXacNhan_dvMouseEntered
        // TODO add your handling code here:
        //btXacNhan.setBackground(Color.red);
    }//GEN-LAST:event_btXacNhan_dvMouseEntered

    private void btXacNhan_dvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btXacNhan_dvActionPerformed
        // TODO add your handling code here:
        String maKhach = cbbMaKhach_dv.getSelectedItem().toString();
        String maPhieuDat = layMaPhieuDat();
        String thanhTien = tfThanhTien_dv.getText();
        Date ngay = dpNgayDat_dv.getDate();
        SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
        String ngayDat = format.format(ngay);
        if (tablePhieuDichVu.getRowCount() == 0) {
            JOptionPane.showMessageDialog(rootPane, "Bạn chưa chọn dịch vụ!");
            return;
        }
        try {
            PhieuDichVu_DTO p = new PhieuDichVu_DTO();
            p.setMaKhach(maKhach);
            p.setMaPhieuDichVu(maPhieuDat);
            p.setTriGia(thanhTien);
            p.setNgayDat(ngayDat);
            PhieuDichVu_BUS.Insert(p);
            for (int i = 0; i < tablePhieuDichVu.getRowCount(); i++) {
                String maCTPhieuDichVu = maCTPhieuDichVu();
                CTPhieuDichVu_DTO ct = new CTPhieuDichVu_DTO();
                ct.setMaCTPhieuDichVu(maCTPhieuDichVu);
                ct.setMaPhieuDichVu(p.getMaPhieuDichVu());
                ct.setMaDichVu(tablePhieuDichVu.getValueAt(i, 0).toString());
                ct.setThanhTien(thanhTien);
                CTPhieuDichVu_BUS.Insert(ct);
            }
            JOptionPane.showMessageDialog(rootPane, "Đặt dịch vụ thành công");
            tableRecords_dv.clear();
            tablePhieuDichVu.setModel(new MyTableModel(tableRecords_dv, tableTitle_dv));
            tfThanhTien_dv.setText("0");
        } catch (Exception ex) {
            Logger.getLogger(PhieuDatTiec.class.getName()).log(Level.SEVERE, null, ex);
        }
        btInPhieu_dv.setEnabled(true);
    }//GEN-LAST:event_btXacNhan_dvActionPerformed

    private void btHuy_dvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btHuy_dvActionPerformed
        // TODO add your handling code here:
        int row = tablePhieuDichVu.getSelectedRow();
        if (row == -1) {
            JOptionPane.showMessageDialog(rootPane, "Bạn chưa chọn dịch vụ!");
            return;
        }
        thanhTien_dv -= Float.parseFloat(tablePhieuDichVu.getValueAt(row, 2).toString());
        tfThanhTien_dv.setText(thanhTien_dv.toString());
        tableRecords_dv.remove(row);
        tablePhieuDichVu.setModel(new MyTableModel(tableRecords_dv, tableTitle_dv));
    }//GEN-LAST:event_btHuy_dvActionPerformed

    private void tableDichVuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableDichVuMouseClicked
        // TODO add your handling code here:
        int row = this.tableDichVu.getSelectedRow();
        for (int i = 0; i < tablePhieuDichVu.getRowCount(); i++) {
            if (tablePhieuDichVu.getValueAt(i, 0) == tableDichVu.getValueAt(row, 0)) {
                return;
            }
        }
        if (row < 0 || row > tableDichVu.getRowCount()) {
            return;
        }
        Vector dichVu = new Vector();
        dichVu.add((String) this.tbModel.getValueAt(row, 0).toString());
        dichVu.add((String) this.tbModel.getValueAt(row, 1).toString());
        dichVu.add((String) this.tbModel.getValueAt(row, 2).toString());
        thanhTien_dv = Float.parseFloat(tfThanhTien_dv.getText());
        thanhTien_dv += Float.parseFloat(tableDichVu.getValueAt(row, 2).toString());
        String strThanhTien = String.format("%f", thanhTien_dv);
        tfThanhTien_dv.setText(strThanhTien);
        tableRecords_dv.add(dichVu);
        tablePhieuDichVu.setModel(new MyTableModel(tableRecords_dv, tableTitle_dv));
    }//GEN-LAST:event_tableDichVuMouseClicked

    private void cbbMaKhach_tiecItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbMaKhach_tiecItemStateChanged
        try {
            // TODO add your handling code here:
            tfTenKhach_tiec.setText(KhachHang_BUS.layTenKHTheoMa(cbbMaKhach_tiec.getSelectedItem().toString()));
        } catch (Exception ex) {
            Logger.getLogger(PhieuDatTiec.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            // TODO add your handling code here:
            tfSoDienThoai_tiec.setText(KhachHang_BUS.laySoDTTheoMa(cbbMaKhach_tiec.getSelectedItem().toString()));
        } catch (Exception ex) {
            Logger.getLogger(PhieuDatTiec.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_cbbMaKhach_tiecItemStateChanged

    private void dpNgayDat_tiecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dpNgayDat_tiecActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_dpNgayDat_tiecActionPerformed

    private void btXacNhan_tiecMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btXacNhan_tiecMouseEntered
        // TODO add your handling code here:
        //btXacNhan.setBackground(Color.red);
    }//GEN-LAST:event_btXacNhan_tiecMouseEntered

    private void btXacNhan_tiecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btXacNhan_tiecActionPerformed
        // TODO add your handling code here:
        String maKhach = cbbMaKhach_tiec.getSelectedItem().toString();
        String maPhieuDat = tfMaPhieuDat_tiec.getText();
        String thanhTien = tfThanhTien_tiec.getText();
        Date ngay = dpNgayDat_tiec.getDate();
        SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
        String ngayDat = format.format(ngay);
        Date today = new Date(System.currentTimeMillis() - 100742784);
        if (tablePhieuDatTiec_tiec.getRowCount() == 0) {
            JOptionPane.showMessageDialog(rootPane, "Bạn chưa chọn món ăn!");
            return;
        }
        if (thanhTien.equals("0")) {
            JOptionPane.showMessageDialog(rootPane, "Bạn chưa chọn số lượng món ăn!");
            return;
        }
        if (ngayDat == null) {
            JOptionPane.showMessageDialog(rootPane, "Bạn chưa chọn ngày đặt tiệc!");
            return;
        }
        int sosanh = ngay.compareTo(today);
        if (sosanh < 0) {
            JOptionPane.showMessageDialog(rootPane, "Ngày đặt phải bằng hoặc sau hiện tại!");
            return;
        }
        try {
            PhieuDatTiec_DTO p = new PhieuDatTiec_DTO();
            p.setMaKhach(maKhach);
            p.setMaPhieuDatTiec(maPhieuDat);
            p.setTriGia(thanhTien);
            p.setNgayDat(ngayDat);
            PhieuDatTiec_BUS.Insert(p);
            for (int i = 0; i < tablePhieuDatTiec_tiec.getRowCount(); i++) {
                int soLuong = Integer.parseInt(tablePhieuDatTiec_tiec.getValueAt(i, 3).toString());
                Float donGia = Float.parseFloat(tablePhieuDatTiec_tiec.getValueAt(i, 2).toString());
                Float tien = (Float) donGia * soLuong;
                String maCTPhieuDatTiec = maCTPhieuDatTiec();
                CTPhieuDatTiec_DTO ct = new CTPhieuDatTiec_DTO();
                ct.setMaCTPhieuDatTiec(maCTPhieuDatTiec);
                ct.setMaMonAn(tablePhieuDatTiec_tiec.getValueAt(i, 0).toString());
                ct.setMaPhieuDatTiec(maPhieuDat);
                ct.setThanhTien(tien.toString());
                ct.setSoLuong(soLuong);
                CTPhieuDatTiec_BUS.Insert(ct);
            }
            JOptionPane.showMessageDialog(rootPane, "Đặt tiệc thành công"); 
            tableRecords_tiec.clear();
            tablePhieuDatTiec_tiec.setModel(new MyTableModel(tableRecords_tiec, tableTitle_tiec));
            tfThanhTien_tiec.setText("0");
            showMaPhieuDat_tiec();
        } catch (Exception ex) {
            Logger.getLogger(PhieuDatTiec.class.getName()).log(Level.SEVERE, null, ex);
        }
        btInPhieu_tiec.setEnabled(true);
    }//GEN-LAST:event_btXacNhan_tiecActionPerformed

    private void btBoMon_tiecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBoMon_tiecActionPerformed
        // TODO add your handling code here:
        int row = tablePhieuDatTiec_tiec.getSelectedRow();
        if (row == -1) {
            JOptionPane.showMessageDialog(rootPane, "Bạn chưa chọn món ăn!");
            return;
        }
        tableRecords_tiec.remove(row);
        tablePhieuDatTiec_tiec.setModel(new MyTableModel(tableRecords_tiec, tableTitle_tiec));
        tfThanhTien_tiec.setText(tinhThanhTien().toString());

    }//GEN-LAST:event_btBoMon_tiecActionPerformed

    private void tableMonAn_tiecMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMonAn_tiecMouseClicked
        // TODO add your handling code here:
        int row = this.tableMonAn_tiec.getSelectedRow();
        if (row < 0 || row > tableMonAn_tiec.getRowCount()) {
            return;
        }
        for (int i = 0; i < tablePhieuDatTiec_tiec.getRowCount(); i++) {
            if (tablePhieuDatTiec_tiec.getValueAt(i, 0) == tableMonAn_tiec.getValueAt(row, 0)) {
                return;
            }
        }
        Vector monAn = new Vector();
        monAn.add((String) this.tbModel_tiec.getValueAt(row, 0).toString());
        monAn.add((String) this.tbModel_tiec.getValueAt(row, 1).toString());
        monAn.add((String) this.tbModel_tiec.getValueAt(row, 2).toString());
        monAn.add("1");
        tableRecords_tiec.add(monAn);
        tablePhieuDatTiec_tiec.setModel(new MyTableModel(tableRecords_tiec, tableTitle_tiec));
        String strThanhTien = String.format("%f", tinhThanhTien());
        tfThanhTien_tiec.setText(strThanhTien);
        tablePhieuDatTiec_tiec.getModel().addTableModelListener(new TableModelListener() {
            @Override
            public void tableChanged(TableModelEvent e) {
                String strThanhTien = String.format("%f", tinhThanhTien());
                tfThanhTien_tiec.setText(strThanhTien);
            }
        });
    }//GEN-LAST:event_tableMonAn_tiecMouseClicked

    private void cbbMaKhach_tiecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbbMaKhach_tiecActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbbMaKhach_tiecActionPerformed
    private void showHoaDon() {
        if (cbbMaKhach_hd.getSelectedItem() == null) {
            return;
        }
        float trigia_phong;
        try {
            trigia_phong = PhieuThuePhong_BUS.layTriGiaTheoMaKhach(cbbMaKhach_hd.getSelectedItem().toString());
            Float trigia_dichvu = PhieuDichVu_BUS.layTriGiaTheoMaKhach(cbbMaKhach_hd.getSelectedItem().toString());
            Float trigia_tiec = PhieuDatTiec_BUS.layTriGiaTheoMaKhach(cbbMaKhach_hd.getSelectedItem().toString());
            Float trigia_huhai = PhieuHuHai_BUS.layTriGiaTheoMaKhach(cbbMaKhach_hd.getSelectedItem().toString());
            Float triGia = trigia_phong + trigia_dichvu + trigia_tiec + trigia_huhai;
            Vector rowData = new Vector();
            rowData.add(String.format("%f", trigia_phong));
            rowData.add(String.format("%f", trigia_dichvu));
            rowData.add(String.format("%f", trigia_tiec));
            rowData.add(String.format("%f", trigia_huhai));
            if (rowData == null) {
                return;
            }
            modelChiPhi.addRow(rowData);
            tbCacKhoanPhi.setModel(modelChiPhi);
            String strTG = String.format("%f", triGia);
            tfTriGia_hd.setText(strTG);
        } catch (Exception ex) {
            Logger.getLogger(HoaDon.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    private void cbbMaKhach_hdItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbMaKhach_hdItemStateChanged
        if (cbbMaKhach_hd.getSelectedItem() == null) {
            return;
        }
        try {
            // TODO add your handling code here:
            tfTenKhach_hd.setText(KhachHang_BUS.layTenKHTheoMa(cbbMaKhach_hd.getSelectedItem().toString()));
            tfSoDienThoai_hd.setText(KhachHang_BUS.laySoDTTheoMa(cbbMaKhach_hd.getSelectedItem().toString()));
        } catch (Exception ex) {
            Logger.getLogger(PhieuDatTiec.class.getName()).log(Level.SEVERE, null, ex);
        }
        showTableChiPhi();
        showHoaDon();


    }//GEN-LAST:event_cbbMaKhach_hdItemStateChanged

    private void cbbMaKhach_hdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbbMaKhach_hdActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbbMaKhach_hdActionPerformed

    private void btLapPhieu_hdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLapPhieu_hdActionPerformed
        // TODO add your handling code here:
        try {
            String mahdMax;
            String mahd;
            mahdMax = HoaDon_BUS.laymaMax();
            if (mahdMax.equals("")) {
                mahd = Phong_BUS.taoMaTuDong("MHD000001", 3);
            } else {
                mahd = Phong_BUS.taoMaTuDong(mahdMax, 3);
            }
            SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
            Date dngayden = dpNgayThanhToan_hd.getDate();
            String ngaythanhtoan = format.format(dngayden);
            HoaDon_DTO h = new HoaDon_DTO();
            h.setMahoaDon(mahd);
            h.setMaKhach(cbbMaKhach_hd.getSelectedItem().toString());
            h.setNgaythanhToan(ngaythanhtoan);
            h.setTriGia(tfTriGia_hd.getText());
            h.setPhiThuePhong(tbCacKhoanPhi.getValueAt(0, 0).toString());
            h.setPhiDichVu(tbCacKhoanPhi.getValueAt(0, 1).toString());
            h.setPhiDatTiec(tbCacKhoanPhi.getValueAt(0, 2).toString());
            h.setPhiHuHai(tbCacKhoanPhi.getValueAt(0, 3).toString());
            HoaDon_BUS.Insert(h);

            ArrayList<CTPhieuThuePhong_DTO> ds = new ArrayList<>();
            ds = CTPhieuThuePhong_BUS.layDsPhongThue(cbbMaKhach_hd.getSelectedItem().toString());

            for (int i = 0; i < ds.size(); i++) {
                String maPhong = ds.get(i).getMaPhong().toString();
                Phong_BUS.capnhattinhtrangDat(maPhong, "Trống");

            }


            KhachHang_BUS.capNhatTinhTrangKhach(cbbMaKhach_hd.getSelectedItem().toString(), "Đã thanh toán");
            JOptionPane.showMessageDialog(rootPane, "Lập phiếu thành công!");
            btInhoadon.setEnabled(true);


        } catch (Exception ex) {
            Logger.getLogger(HoaDon.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_btLapPhieu_hdActionPerformed

    private void btLapBaoCaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLapBaoCaoActionPerformed
        // TODO add your handling code here:
        String thang;
        if (tfNam.getText().equals("")) {
            JOptionPane.showMessageDialog(pnHoaDon, "Bạn chưa nhập năm vào!");
            return;
        }
        thang = cbThang.getSelectedItem().toString() + "-" + tfNam.getText();
        try {
            new ShowReport().Show_ReportDoanhThu(thang);
        } catch (JRException ex) {
            Logger.getLogger(BaoCaoDoanhThuTheoLoaiPhong.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(BaoCaoDoanhThuTheoLoaiPhong.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(BaoCaoDoanhThuTheoLoaiPhong.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(BaoCaoDoanhThuTheoLoaiPhong.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btLapBaoCaoActionPerformed

    private void tpQuanLyComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_tpQuanLyComponentShown
        // TODO add your handling code here:
//        int index=tpQuanLy.getSelectedIndex();
//        switch(index){
//            case 0: 
//                        //Show cho form đặt phòng
//        showDSPhongTrong();
//        showDSPhongDat();
//                break;
//                
//        }
    }//GEN-LAST:event_tpQuanLyComponentShown

    private void tpQuanLyStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tpQuanLyStateChanged
        // TODO add your handling code here:
        int index = tpQuanLy.getSelectedIndex();
        switch (index) {
            case 0:
                //Show cho form đặt phòng
                showDSPhongTrong();
                showDSPhongDat();
                break;
            case 1:
                //Show cho form thuê phòng
                showPhongDeThue();
                showTablePhongThue();
                huyPhieuDatQuaHan();
                break;
            case 2:

                //show form dịch vụ
                showCbbMaKhach_dv();
                showBangDichVu();
                tableTitle_dv.clear();
                tableTitle_dv.add("Mã Dịch Vụ");
                tableTitle_dv.add("Tên Dịch Vụ");
                tableTitle_dv.add("Đơn Giá");
                tablePhieuDichVu.setModel(new MyTableModel(tableRecords_dv, tableTitle_dv));
                break;
            case 3:
                //show form tiec
                showCbbMaKhach_tiec();
                showBangMonAn();
                showMaPhieuDat_tiec();
                tableTitle_tiec.clear();
                tableTitle_tiec.add("Mã Món Ăn");
                tableTitle_tiec.add("Tên Món Ăn");
                tableTitle_tiec.add("Đơn Giá");
                tableTitle_tiec.add("Số Lượng");
                tablePhieuDatTiec_tiec.setModel(new MyTableModel(tableRecords_tiec, tableTitle_tiec));
                break;
            case 4:
                //show form hu hai
                showCbbMaKhach_huhai();
                showDanhSach_huhai();
                break;
            case 5:
                //show hd
                showCbbMaKhach_hd();
                showTableChiPhi();
                showHoaDon();
                break;
        }
    }//GEN-LAST:event_tpQuanLyStateChanged

    private void formComponentMoved(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_formComponentMoved
        // TODO add your handling code here:
        this.setLocationRelativeTo(FrameMenu.menu.pannelDestop);
    }//GEN-LAST:event_formComponentMoved

    private void cbbMaKhach_huhaiItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbbMaKhach_huhaiItemStateChanged
        try {
            // TODO add your handling code here:
            tfTenKhach_huhai.setText(KhachHang_BUS.layTenKHTheoMa(cbbMaKhach_huhai.getSelectedItem().toString()));
        } catch (Exception ex) {
            Logger.getLogger(PhieuDatTiec.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            // TODO add your handling code here:
            tfSoDienThoai_huhai.setText(KhachHang_BUS.laySoDTTheoMa(cbbMaKhach_huhai.getSelectedItem().toString()));
        } catch (Exception ex) {
            Logger.getLogger(PhieuDatTiec.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_cbbMaKhach_huhaiItemStateChanged

    private void cbbMaKhach_huhaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbbMaKhach_huhaiActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cbbMaKhach_huhaiActionPerformed

    private void btLapPhieuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLapPhieuActionPerformed
        // TODO add your handling code here:
        String maphieumax;
        String maphieu;
        try {
            maphieumax = PhieuHuHai_BUS.laymaMax();
            if (maphieumax.equals("")) {
                maphieu = Phong_BUS.taoMaTuDong("MPHH000000", 4);
            } else {
                maphieu = Phong_BUS.taoMaTuDong(maphieumax, 4);
            }
            String noidunghuHai = taNoiDungHuHai.getText();
            String triGia = tfTriGia.getText();
            try {
                Float tg = Float.parseFloat(triGia);
                if (tg < 0 || tg > 100000000) {
                    JOptionPane.showMessageDialog(rootPane, "Trị giá phải là số từ 0 đến 100.000.000!");
                    tfTriGia.setText("0");
                    return;
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(rootPane, "Trị giá phải là số từ 0 đến 100.000.000!");
                return;
            }
            if (noidunghuHai.equals("") || triGia.equals("")) {
                JOptionPane.showMessageDialog(rootPane, "Bạn phải nhập nội dung hư hại và trị giá!");
                return;
            }
            String maKhach = cbbMaKhach_huhai.getSelectedItem().toString();
            PhieuHuHai_DTO p = new PhieuHuHai_DTO();
            p.setMaphieuhuHai(maphieu);
            p.setMaKhach(maKhach);
            p.setNoidunghuHai(noidunghuHai);
            p.setTriGia(triGia);

            PhieuHuHai_BUS.Insert(p);
            JOptionPane.showMessageDialog(rootPane, "Lập phiếu thành công!");

            showDanhSach_huhai();

        } catch (Exception ex) {
            Logger.getLogger(PhieuHuHai.class.getName()).log(Level.SEVERE, null, ex);
        }
        btInphieu_hh.setEnabled(true);

    }//GEN-LAST:event_btLapPhieuActionPerformed

    private void tablebPhongChon_datMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablebPhongChon_datMouseClicked
        // TODO add your handling code here:
        int row = tablebPhongChon_dat.getSelectedRow();
        Vector rowData = new Vector();
        String maPhong = (String) this.modelPhongDat.getValueAt(row, 0).toString();
        String tenLoaiPhong = (String) this.modelPhongDat.getValueAt(row, 1).toString();
        String donGia = (String) this.modelPhongDat.getValueAt(row, 2).toString();
        rowData.add(maPhong);
        rowData.add(tenLoaiPhong);
        rowData.add(donGia);
        modelPhongTrong.addRow(rowData);
        tablePhongTrong_dat.setModel(modelPhongTrong);
        modelPhongDat.removeRow(row);
    }//GEN-LAST:event_tablebPhongChon_datMouseClicked

    private void tbPhongChon_thueMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbPhongChon_thueMouseClicked
        // TODO add your handling code here:
        int row = tbPhongChon_thue.getSelectedRow();
        Vector rowData = new Vector();
        String maPhong = (String) this.modelPhongThue.getValueAt(row, 0).toString();
        String tenLoaiPhong = (String) this.modelPhongThue.getValueAt(row, 1).toString();
        String donGia = (String) this.modelPhongThue.getValueAt(row, 2).toString();
        rowData.add(maPhong);
        rowData.add(tenLoaiPhong);
        rowData.add(donGia);
        modelPhongDeThue.addRow(rowData);
        tbPhongTrong_thue.setModel(modelPhongDeThue);
        modelPhongThue.removeRow(row);
    }//GEN-LAST:event_tbPhongChon_thueMouseClicked

    private void tablePhieuDatTiec_tiecMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablePhieuDatTiec_tiecMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_tablePhieuDatTiec_tiecMouseClicked

    private void btInPhieu_tiecMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btInPhieu_tiecMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_btInPhieu_tiecMouseEntered

    private void btInPhieu_tiecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInPhieu_tiecActionPerformed
        // TODO add your handling code here:
        
        try {
            String maPhieuDat = PhieuDatTiec_BUS.layMaCuoiCung();
            new ShowReport().Show_ReportDatTiec(maPhieuDat);
        } catch (JRException ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        }    
           btInPhieu_tiec.setEnabled(false);
        
        
    }//GEN-LAST:event_btInPhieu_tiecActionPerformed

    private void btInhoadonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInhoadonActionPerformed
        try {
            // TODO add your handling code here:
                        new ShowReport().Show_ReportHoaDon(cbbMaKhach_hd.getSelectedItem().toString());
        } catch (JRException ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        }
            cbbMaKhach_hd.removeAllItems();
            showCbbMaKhach_hd();
            btInhoadon.setEnabled(false);
    }//GEN-LAST:event_btInhoadonActionPerformed

    private void btInPhieu_dvMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btInPhieu_dvMouseEntered
        // TODO add your handling code here:
    }//GEN-LAST:event_btInPhieu_dvMouseEntered

    private void btInPhieu_dvActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInPhieu_dvActionPerformed
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(pnHoaDon, "Chưa làm xong");
        btInPhieu_dv.setEnabled(false);
    }//GEN-LAST:event_btInPhieu_dvActionPerformed

    private void btInphieu_hhActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btInphieu_hhActionPerformed
        try {
            String makhach=cbbMaKhach_huhai.getSelectedItem().toString();
            new ShowReport().Show_ReportHuHai(makhach);
            
        } catch (JRException ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(FrameQuanLy.class.getName()).log(Level.SEVERE, null, ex);
        }
        taNoiDungHuHai.setText("");
        tfTriGia.setText("");
        modelDs_huhai.setNumRows(0);   
        btInphieu_hh.setEnabled(false);
        
    }//GEN-LAST:event_btInphieu_hhActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrameQuanLy.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrameQuanLy.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrameQuanLy.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrameQuanLy.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new FrameQuanLy().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane Pannel;
    private javax.swing.JScrollPane Pannel2;
    private javax.swing.JButton btBoMon_tiec;
    private javax.swing.JButton btHuy_dv;
    private javax.swing.JButton btInPhieu_dv;
    private javax.swing.JButton btInPhieu_thue;
    private javax.swing.JButton btInPhieu_tiec;
    private javax.swing.JButton btInhoadon;
    private javax.swing.JButton btInphieu_hh;
    private javax.swing.JButton btLapBaoCao;
    private javax.swing.JButton btLapPhieu;
    private javax.swing.JButton btLapPhieu_dat;
    private javax.swing.JButton btLapPhieu_hd;
    private javax.swing.JButton btLapPhieu_thue;
    private javax.swing.JButton btXacNhan_dv;
    private javax.swing.JButton btXacNhan_tiec;
    private javax.swing.JComboBox cbThang;
    private javax.swing.JComboBox cbbMaKhach_dv;
    private javax.swing.JComboBox cbbMaKhach_hd;
    private javax.swing.JComboBox cbbMaKhach_huhai;
    private javax.swing.JComboBox cbbMaKhach_tiec;
    private javax.swing.JComboBox cbbSoKhach_dat;
    private javax.swing.JComboBox cbbSoKhach_thue;
    private org.jdesktop.swingx.JXDatePicker dpNgayDat_dv;
    private org.jdesktop.swingx.JXDatePicker dpNgayDat_tiec;
    private org.jdesktop.swingx.JXDatePicker dpNgayDen_dat;
    private org.jdesktop.swingx.JXDatePicker dpNgayDi_dat;
    private org.jdesktop.swingx.JXDatePicker dpNgayThanhToan_hd;
    private org.jdesktop.swingx.JXDatePicker dpNgayThue_thue;
    private org.jdesktop.swingx.JXDatePicker dpNgayTra_thue;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane10;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JPanel pannelBaoCao;
    private javax.swing.JPanel pannelHuHai;
    private javax.swing.JPanel pnDatTiec;
    private javax.swing.JPanel pnDichVu;
    private javax.swing.JPanel pnHoaDon;
    private javax.swing.JPanel pnPhieuDat;
    private javax.swing.JPanel pnPhieuThue;
    private javax.swing.JTextArea taNoiDungHuHai;
    private org.jdesktop.swingx.JXTable tableDichVu;
    private org.jdesktop.swingx.JXTable tableMonAn_tiec;
    private org.jdesktop.swingx.JXTable tablePhieuDatTiec_tiec;
    private org.jdesktop.swingx.JXTable tablePhieuDichVu;
    private javax.swing.JTable tablePhongTrong_dat;
    private javax.swing.JTable tablebPhongChon_dat;
    private javax.swing.JTable tbCacKhoanPhi;
    private javax.swing.JTable tbDanhSach_huhai;
    private javax.swing.JTable tbKhachDatPhong;
    private javax.swing.JTable tbPhongChon_thue;
    private javax.swing.JTable tbPhongTrong_thue;
    private javax.swing.JTextField tfCMND_dat;
    private javax.swing.JTextField tfCMND_thue;
    private javax.swing.JTextField tfEmail_thue;
    private javax.swing.JTextField tfMaPhieuDat_tiec;
    private javax.swing.JTextField tfNam;
    private javax.swing.JTextField tfSoDienThoai_dat;
    private javax.swing.JTextField tfSoDienThoai_dv;
    private javax.swing.JTextField tfSoDienThoai_hd;
    private javax.swing.JTextField tfSoDienThoai_huhai;
    private javax.swing.JTextField tfSoDienThoai_thue;
    private javax.swing.JTextField tfSoDienThoai_tiec;
    private javax.swing.JTextField tfTenKhachHang_dat;
    private javax.swing.JTextField tfTenKhachHang_thue;
    private javax.swing.JTextField tfTenKhach_dv;
    private javax.swing.JTextField tfTenKhach_hd;
    private javax.swing.JTextField tfTenKhach_huhai;
    private javax.swing.JTextField tfTenKhach_tiec;
    private javax.swing.JTextField tfThanhTien_dv;
    private javax.swing.JTextField tfThanhTien_tiec;
    private javax.swing.JTextField tfTriGia;
    private javax.swing.JTextField tfTriGia_dat;
    private javax.swing.JTextField tfTriGia_hd;
    private javax.swing.JTextField tfTriGia_thue;
    private javax.swing.JTextField tfemail_dat;
    private javax.swing.JTabbedPane tpQuanLy;
    // End of variables declaration//GEN-END:variables


}
